package com.example.mapstructexample.mapper;

import com.example.mapstructexample.bean.Car;
import com.example.mapstructexample.vo.CarVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface CarMapper {
    //映射器工厂
    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);


    @Mappings({@Mapping(source = "name", target = "nameVo")
            , @Mapping(source = "color", target = "colorVo")})
    CarVo toCarVo(Car car);


    List<CarVo> toCarVoList(List<Car> carList);

    @Mappings({@Mapping(source = "name", target = "nameVo")
            , @Mapping(source = "color", target = "colorVo")})
    void updateCarVo(Car car, @MappingTarget CarVo carVo);
}
